//
//  CSTutorialController.m
//  CreateWithSuper
//
//  Created by chenjunbo on 2024/6/1.
//  Copyright © 2024 CS. All rights reserved.
//

#import "CSTutorialController.h"
#import "CSCreateController.h"
#import "ADModule.h"

@interface CSTutorialController ()<UIScrollViewDelegate>

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIImageView *topImgView;
@property (weak, nonatomic) IBOutlet UILabel *topLabel;
@property (weak, nonatomic) IBOutlet UILabel *smallLabel;
@property (weak, nonatomic) IBOutlet UIImageView *smallImgView;
@property (weak, nonatomic) IBOutlet UIButton *btn;

@end

@implementation CSTutorialController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    NSLog(@"%f",scrollView.contentOffset.x);
    if (scrollView.contentOffset.x == 0){
        self.topImgView.image = [UIImage imageNamed:@"icon_guide_01"];
        self.smallImgView.image = [UIImage imageNamed:@"icon_indicate_01"];
        self.topLabel.text = @"AI painting";
        self.smallLabel.text = @"Text generated painting";
        [self.btn setTitle:@"Next" forState:UIControlStateNormal];
    }
    
    if (scrollView.contentOffset.x == self.view.frame.size.width){
        self.topImgView.image = [UIImage imageNamed:@"icon_guide_02"];
        self.smallImgView.image = [UIImage imageNamed:@"icon_indicate_02"];
        self.topLabel.text = @"Connect your proxy";
        self.smallLabel.text = @"Hide your real lP and encrypt your network..";
        [self.btn setTitle:@"Next" forState:UIControlStateNormal];
    }
    
    if (scrollView.contentOffset.x == self.view.frame.size.width * 2){
        self.topImgView.image = [UIImage imageNamed:@"icon_guide_03"];
        self.smallImgView.image = [UIImage imageNamed:@"icon_indicate_03"];
        self.topLabel.text = @"Unlimited AI";
        self.smallLabel.text = @"Freely generate any content";
        [self.btn setTitle:@"Continue" forState:UIControlStateNormal];
    }
    
}

- (IBAction)btnClick:(UIButton *)sender {
    if (self.scrollView.contentOffset.x == 0){
        [self.scrollView setContentOffset:CGPointMake(self.view.frame.size.width, 0)];
    }else if (self.scrollView.contentOffset.x == self.view.frame.size.width){
        [self.scrollView setContentOffset:CGPointMake(self.view.frame.size.width * 2, 0)];

    }else if (self.scrollView.contentOffset.x == self.view.frame.size.width * 2){
        
        [[ADModule standardInstance]showInterAdWithVC:self dismiss:^{
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Create" bundle:nil];
            CSCreateController *vc = [storyboard instantiateViewControllerWithIdentifier:@"CSCreateController"];
            
            UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
            
            [UIApplication sharedApplication].keyWindow.rootViewController = nav;

            [[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"ShowedCSTutorialController"];
        }];

    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
